<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        input{
            width: 300px;
            height: 30px;
            border: 1px solid black;
        }
        img{
            width: 30px;
            position: relative;
            top: 4px;
            left: -40px;
        }
    </style>
</head>
<body>
    <!-- password -->
    <input type="password">
    <img src="./关.jpg" alt="">
    <script>
        var oImg = document.querySelector("img");
        var inp = document.querySelector("input");
        var a = true;
        oImg.onclick = function(){
            if(a==true){
                oImg.src = "./开.jpg";
                inp.type="text";
                a = false;
            }else if(a==false){
                oImg.src = "./关.jpg";
                inp.type="password"
                a = true;
            }
        }
    </script>
</body>
</html>